@dfns/sdk 0.5.9 → 0.5.10-alpha.2

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.
@@ -0,0 +1,8 @@
1
+ import { DfnsApiClientOptions } from '../../types/generic';
2
+ import * as T from './types';
3
+ export declare class StakingClient {
4
+ private apiOptions;
5
+ constructor(apiOptions: DfnsApiClientOptions);
6
+ createStake(request: T.CreateStakeRequest): Promise<T.CreateStakeResponse>;
7
+ listStakes(request?: T.ListStakesRequest): Promise<T.ListStakesResponse>;
8
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StakingClient = void 0;
4
+ const fetch_1 = require("../../utils/fetch");
5
+ const userActionFetch_1 = require("../../utils/userActionFetch");
6
+ const url_1 = require("../../utils/url");
7
+ class StakingClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createStake(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
17
+ method: 'POST',
18
+ body: request.body,
19
+ apiOptions: this.apiOptions,
20
+ });
21
+ return response.json();
22
+ }
23
+ async listStakes(request) {
24
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
25
+ path: request ?? {},
26
+ query: request?.query ?? {},
27
+ });
28
+ const response = await (0, fetch_1.simpleFetch)(path, {
29
+ method: 'GET',
30
+ apiOptions: this.apiOptions,
31
+ });
32
+ return response.json();
33
+ }
34
+ }
35
+ exports.StakingClient = StakingClient;
@@ -0,0 +1,10 @@
1
+ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
2
+ import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
3
+ import * as T from './types';
4
+ export declare class DelegatedStakingClient {
5
+ private apiOptions;
6
+ constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ createStakeInit(request: T.CreateStakeRequest): Promise<UserActionChallengeResponse>;
8
+ createStakeComplete(request: T.CreateStakeRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateStakeResponse>;
9
+ listStakes(request?: T.ListStakesRequest): Promise<T.ListStakesResponse>;
10
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedStakingClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedStakingClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createStakeInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
17
+ userActionHttpMethod: 'POST',
18
+ userActionHttpPath: path,
19
+ userActionPayload: JSON.stringify(request.body),
20
+ userActionServerKind: 'Api',
21
+ }, this.apiOptions);
22
+ return challenge;
23
+ }
24
+ async createStakeComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
26
+ path: request ?? {},
27
+ query: {},
28
+ });
29
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
30
+ const response = await (0, fetch_1.simpleFetch)(path, {
31
+ method: 'POST',
32
+ body: request.body,
33
+ headers: { 'x-dfns-useraction': userAction },
34
+ apiOptions: this.apiOptions,
35
+ });
36
+ return response.json();
37
+ }
38
+ async listStakes(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
40
+ path: request ?? {},
41
+ query: request?.query ?? {},
42
+ });
43
+ const response = await (0, fetch_1.simpleFetch)(path, {
44
+ method: 'GET',
45
+ apiOptions: this.apiOptions,
46
+ });
47
+ return response.json();
48
+ }
49
+ }
50
+ exports.DelegatedStakingClient = DelegatedStakingClient;
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './client';
3
+ export * from './delegatedClient';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./delegatedClient"), exports);
@@ -0,0 +1,99 @@
1
+ export type CreateStakeBody = {
2
+ kind: "Native";
3
+ amount: string;
4
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
5
+ createDestinationAccount?: boolean | undefined;
6
+ externalId?: string | undefined;
7
+ walletId: string;
8
+ provider: "Figment";
9
+ protocol: "Babylon";
10
+ duration: number;
11
+ };
12
+ export type CreateStakeResponse = {
13
+ stake: {
14
+ id: string;
15
+ provider: "Figment";
16
+ providerStakeId: string;
17
+ walletId: string;
18
+ protocol: "Babylon";
19
+ status: "Active";
20
+ requester: {
21
+ userId: string;
22
+ tokenId?: string | undefined;
23
+ appId?: string | undefined;
24
+ };
25
+ requestBody: {
26
+ kind: "Native";
27
+ amount: string;
28
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
29
+ createDestinationAccount?: boolean | undefined;
30
+ externalId?: string | undefined;
31
+ walletId: string;
32
+ provider: "Figment";
33
+ protocol: "Babylon";
34
+ duration: number;
35
+ };
36
+ dateCreated: string;
37
+ };
38
+ stakeTransaction: {
39
+ id: string;
40
+ stakeId: string;
41
+ transactionId?: string | undefined;
42
+ kind: "Stake" | "Unbond" | "UnbondWithdrawal" | "Withdraw";
43
+ requester: {
44
+ userId: string;
45
+ tokenId?: string | undefined;
46
+ appId?: string | undefined;
47
+ };
48
+ requestBody: {
49
+ kind: "Native";
50
+ amount: string;
51
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
52
+ createDestinationAccount?: boolean | undefined;
53
+ externalId?: string | undefined;
54
+ walletId: string;
55
+ provider: "Figment";
56
+ protocol: "Babylon";
57
+ duration: number;
58
+ };
59
+ dateCreated: string;
60
+ };
61
+ };
62
+ export type CreateStakeRequest = {
63
+ body: CreateStakeBody;
64
+ };
65
+ export type ListStakesQuery = {
66
+ limit?: number | undefined;
67
+ paginationToken?: string | undefined;
68
+ };
69
+ export type ListStakesResponse = {
70
+ items: {
71
+ id: string;
72
+ provider: "Figment";
73
+ providerStakeId: string;
74
+ walletId: string;
75
+ protocol: "Babylon";
76
+ status: "Active";
77
+ requester: {
78
+ userId: string;
79
+ tokenId?: string | undefined;
80
+ appId?: string | undefined;
81
+ };
82
+ requestBody: {
83
+ kind: "Native";
84
+ amount: string;
85
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
86
+ createDestinationAccount?: boolean | undefined;
87
+ externalId?: string | undefined;
88
+ walletId: string;
89
+ provider: "Figment";
90
+ protocol: "Babylon";
91
+ duration: number;
92
+ };
93
+ dateCreated: string;
94
+ }[];
95
+ nextPageToken?: string | undefined;
96
+ };
97
+ export type ListStakesRequest = {
98
+ query?: ListStakesQuery;
99
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });